package com.rxkj.config;

import com.rxkj.authen.AuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 请求拦截器配置类，用于拦截所有请求
 * 加载处理请求的拦截器bean
 * by alex
 * 2022-4-7
 */
@Configuration
public class RequestIntercetporConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor())
                .addPathPatterns("/**") // 拦截所有请求 ，除PassToken注解
                .excludePathPatterns("/player/**","/doc.html","/swagger-ui.html","/swagger-resources/**","/webjars/**","/v2/**","/api/**");
    }
    @Bean
    public AuthenticationInterceptor authenticationInterceptor() {
        return new AuthenticationInterceptor();
    }
}
